home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / term / term_47a_pch.lha / Source / gtlayout-38.3 / LTP_DetermineSize.c < prev    next >
C/C++ Source or Header  |  1996-11-11  |  23KB  |  977 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. LONG
  15. LTP_GetPickerSize(LayoutHandle *Handle)
  16. {
  17.     LONG margin,width;
  18.  
  19.     width = (Handle->TextAttr->ta_YSize * Handle->AspectY) / Handle->AspectX;
  20.  
  21.     if(width < 8)
  22.         width = 8;
  23.  
  24.     margin = 2 + (width + 15) / 16;
  25.  
  26.     return((LONG)(margin + (((115 * width) / 150) & ~1) + 1 + margin));
  27. }
  28.  
  29. VOID
  30. LTP_DetermineSize(LayoutHandle *Handle,ObjectNode *Node)
  31. {
  32.     if(!Handle->Failed)
  33.     {
  34.         LONG i,Len,Width,Max,Plus;
  35.  
  36.         if(Node->Label)
  37.         {
  38.             LONG LabelWidth = LT_LabelWidth(Handle,Node->Label);
  39.  
  40.             if(Node->LabelChars * Handle->GlyphWidth > LabelWidth)
  41.                 LabelWidth = Node->LabelChars * Handle->GlyphWidth;
  42.  
  43.             Node->LabelWidth = LabelWidth;
  44.         }
  45.         else
  46.             Node->LabelWidth = 0;
  47.  
  48.         switch(Node->Type)
  49.         {
  50. #ifdef DO_BOOPSI_KIND
  51.             case BOOPSI_KIND:
  52.  
  53.                 if(Node->Special.BOOPSI.ExactWidth)
  54.                     Node->Width = Node->Special.BOOPSI.ExactWidth;
  55.                 else
  56.                     Node->Width = Node->Chars * Handle->GlyphWidth;
  57.  
  58.                 if(Node->Special.BOOPSI.ExactHeight)
  59.                     Node->Height = Node->Special.BOOPSI.ExactHeight;
  60.                 else
  61.                     Node->Height = Node->Lines * Handle->GlyphHeight;
  62.  
  63.                 if(Node->Special.BOOPSI.RelFontHeight)
  64.                     Node->Height = Handle->GlyphHeight + Node->Special.BOOPSI.RelFontHeight;
  65.  
  66.                 break;
  67. #endif    /* DO_BOOPSI_KIND */
  68.  
  69. #ifdef DO_LEVEL_KIND
  70.             case LEVEL_KIND:
  71.  
  72.                 Node->Width        = 6 + Node->Chars * Handle->GlyphWidth + 6;
  73.                 Node->Height    = 2 + Handle->GlyphHeight + 1;
  74.  
  75.                 LTP_GetStorage(Node);
  76.  
  77.                 if(Node->Current > Node->Max)
  78.                 {
  79.                     Node->Current = Node->Max;
  80.  
  81.                     LTP_PutStorage(Node);
  82.                 }
  83.  
  84.                 if(Node->Current < Node->Min)
  85.                 {
  86.                     Node->Current = Node->Min;
  87.  
  88.                     LTP_PutStorage(Node);
  89.                 }
  90.  
  91.                 if(!Node->Special.Level.MaxLevelWidth || Handle->Rescaled)
  92.                 {
  93.                     LTP_LevelWidth(Handle,Node->Special.Level.LevelFormat,Node->Special.Level.DispFunc,Node->Min,Node->Max,&Node->Special.Level.MaxLevelWidth,NULL,Node->Special.Level.FullLevelCheck);
  94.  
  95.                     Node->Special.Level.MaxLevelWidth += TextLength(&Handle->RPort," ",1);
  96.                 }
  97.  
  98.                 Node->Special.Level.Handle                = Handle;
  99.                 Node->Special.Level.CustomHook.h_Entry    = (HOOKFUNC)LTP_LevelGadgetDispatcher;
  100.  
  101.                 if(!Node->Special.Level.Plus)
  102.                     Node->Special.Level.Plus = Node->Min;
  103.  
  104.                 if(Node->LabelChars * Handle->GlyphWidth > Node->LabelWidth)
  105.                     Node->LabelWidth = Node->LabelChars * Handle->GlyphWidth;
  106.  
  107.                 if(Node->Special.Level.LevelPlace == PLACETEXT_LEFT && Node->LabelPlace == PLACE_LEFT)
  108.                     Node->LabelWidth += Node->Special.Level.MaxLevelWidth;
  109.  
  110.                 break;
  111. #endif    /* DO_LEVEL_KIND */
  112.             case GROUP_KIND:
  113.  
  114.                 LTP_LayoutGroup(Handle,Node);
  115.  
  116.                 break;
  117.  
  118.             case XBAR_KIND:
  119.  
  120.                 Node->Width        = Handle->GlyphWidth;
  121.                 Node->Height    = 6;
  122.  
  123.                 break;
  124.  
  125.             case YBAR_KIND:
  126.  
  127.                 Node->Width        = 6;
  128.                 Node->Height    = Handle->GlyphHeight;
  129.  
  130.                 break;
  131.  
  132.             case FRAME_KIND:
  133.  
  134.                 if(Node->Special.Frame.DrawBox)
  135.                 {
  136.                     Node->Width        = 4 + Node->Special.Frame.InnerWidth + 4;
  137.                     Node->Height    = 2 + Node->Special.Frame.InnerHeight + 2;
  138.                 }
  139.                 else
  140.                 {
  141.                     Node->Width        = Node->Special.Frame.InnerWidth;
  142.                     Node->Height    = Node->Special.Frame.InnerHeight;
  143.                 }
  144.  
  145.                 break;
  146.  
  147.             case BOX_KIND:
  148.  
  149.                 Node->LabelWidth = 0;
  150.  
  151.                 if(Node->Special.Box.Labels)
  152.                 {
  153.                     for(i = 0 ; i < Node->Lines ; i++)
  154.                     {
  155.                         if((Width = TextLength(&Handle->RPort,Node->Special.Box.Labels[i],strlen(Node->Special.Box.Labels[i]))) > Node->LabelWidth)
  156.                             Node->LabelWidth = Width;
  157.                     }
  158.                 }
  159.  
  160.                 if(Node->LabelChars)
  161.                 {
  162.                     if(Node->LabelChars * Handle->GlyphWidth > Node->LabelWidth)
  163.                         Node->LabelWidth = Node->LabelChars * Handle->GlyphWidth;
  164.                     else
  165.                         Node->LabelWidth = ((Node->LabelWidth + Node->LabelChars - 1) / Node->LabelChars) * Node->LabelChars;
  166.                 }
  167.  
  168.                 Max = Node->Chars;
  169.  
  170.                 if(Node->Special.Box.Lines)
  171.                 {
  172.                     LONG MaxWidth = 0;
  173.  
  174.                     for(i = 0 ; i < Node->Lines ; i++)
  175.                     {
  176.                         if(Node->Special.Box.Lines[i])
  177.                         {
  178.                             if(Len = strlen(Node->Special.Box.Lines[i]))
  179.                             {
  180.                                 if((Width = TextLength(&Handle->RPort,Node->Special.Box.Lines[i],Len)) > MaxWidth)
  181.                                     MaxWidth = Width;
  182.                             }
  183.                         }
  184.                     }
  185.  
  186.                     if(Max < (MaxWidth + Handle->GlyphWidth - 1) / Handle->GlyphWidth)
  187.                         Max = (MaxWidth + Handle->GlyphWidth - 1) / Handle->GlyphWidth;
  188.                 }
  189.  
  190.                 Node->Height    = 2 + Node->Lines * Handle->GlyphHeight + 2;
  191.                 Node->Width        = 4 + Max * Handle->GlyphWidth + 4;
  192.  
  193.                 break;
  194.  
  195.             case BLANK_KIND:
  196.  
  197.                 Node->Width            = Handle->GlyphWidth;
  198.                 Node->Height        = Handle->GlyphHeight;
  199.                 Node->Label            = "";
  200.                 Node->LabelWidth    = 0;
  201.                 Node->LabelPlace    = PLACE_IN;
  202.  
  203.                 break;
  204.  
  205.             case BUTTON_KIND:
  206.  
  207.                 if(!Node->Special.Button.Lines && Node->Label)
  208.                 {
  209.                     LONG i,Len = strlen(Node->Label),Count = 0;
  210.  
  211.                     for(i = 0 ; i < Len ; i++)
  212.                     {
  213.                         if(Node->Label[i] == '\n')
  214.                             Count++;
  215.                     }
  216.  
  217.                     if(Count)
  218.                     {
  219.                         STRPTR *Lines;
  220.  
  221.                         if(Lines = (STRPTR *)LTP_Alloc(Handle,(Count + 2) * sizeof(STRPTR) + Len + 1))
  222.                         {
  223.                             STRPTR String = (STRPTR)(&Lines[Count + 2]);
  224.  
  225.                             strcpy(String,Node->Label);
  226.  
  227.                             Node->Special.Button.Lines = Lines;
  228.  
  229.                             if(Node->Special.Button.KeyStroke)
  230.                                 Node->Special.Button.KeyStroke = &String[((ULONG)Node->Special.Button.KeyStroke) - ((ULONG)Node->Label)];
  231.  
  232.                             do
  233.                             {
  234.                                 *Lines++ = String;
  235.  
  236.                                 for(i = 0 ; String[i] ; i++)
  237.                                 {
  238.                                     if(String[i] == '\n')
  239.                                     {
  240.                                         String[i] = 0;
  241.  
  242.                                         String = &String[i + 1];
  243.  
  244.                                         break;
  245.                                     }
  246.                                 }
  247.                             }
  248.                             while(Count--);
  249.                         }
  250.                         else
  251.                             break;
  252.                     }
  253.                 }
  254.  
  255.                 if(Node->Special.Button.Lines)
  256.                 {
  257.                     STRPTR    *Index = Node->Special.Button.Lines;
  258.                     LONG     Count = 0,Width,MaxWidth = 0,Height;
  259.  
  260.                     while(*Index)
  261.                     {
  262.                         Count++;
  263.  
  264.                         if((Width = LT_LabelWidth(Handle,*Index)) > MaxWidth)
  265.                             MaxWidth = Width;
  266.  
  267.                         Index++;
  268.                     }
  269.  
  270.                     Node->Special.Button.LineCount = Count;
  271.  
  272.                     if(Node->Chars * Handle->GlyphWidth > MaxWidth)
  273.                         MaxWidth = Node->Chars * Handle->GlyphWidth;
  274.  
  275.                     if(Node->Lines > Count)
  276.                         Count = Node->Lines;
  277.  
  278.                     Height = Count * Handle->GlyphHeight;
  279.  
  280.                     if(Node->Special.Button.ExtraFat)
  281.                     {
  282.                         Node->Width        = 6 + Handle->GlyphWidth + MaxWidth + Handle->GlyphWidth + 6;
  283.                         Node->Height    = 2 + (2 * Height + Handle->GlyphHeight) / 2 + 2;
  284.                     }
  285.                     else
  286.                     {
  287.                         if(Node->Special.Button.Smaller)
  288.                         {
  289.                             Node->Width        = 4 + MaxWidth + 4;
  290.                             Node->Height    = 2 + Height + 2;
  291.                         }
  292.                         else
  293.                         {
  294.                             Node->Width        = 6 + MaxWidth + 6;
  295.                             Node->Height    = 3 + Height + 3;
  296.                         }
  297.                     }
  298.  
  299.                     Node->Label = "";
  300.                 }
  301.                 else
  302.                 {
  303.                     if(Node->Chars * Handle->GlyphWidth > Node->LabelWidth)
  304.                         Node->Width = Node->Chars * Handle->GlyphWidth;
  305.                     else
  306.                         Node->Width = Node->LabelWidth;
  307.  
  308.                     if(Node->Lines)
  309.                     {
  310.                         if(Node->Special.Button.ExtraFat)
  311.                         {
  312.                             Node->Width        = 6 + Handle->GlyphWidth + Node->Width + Handle->GlyphWidth + 6;
  313.                             Node->Height    = 2 + ((Node->Lines + 1) * Handle->GlyphHeight) / 2 + 2;
  314.                         }
  315.                         else
  316.                         {
  317.                             if(Node->Special.Button.Smaller)
  318.                             {
  319.                                 Node->Width        = 4 + Node->Width + 4;
  320.                                 Node->Height    = 2 + (Node->Lines * Handle->GlyphHeight) + 2;
  321.                             }
  322.                             else
  323.                             {
  324.                                 Node->Width        = 6 + Node->Width + 6;
  325.                                 Node->Height    = 3 + (Node->Lines * Handle->GlyphHeight) + 3;
  326.                             }
  327.                         }
  328.                     }
  329.                     else
  330.                     {
  331.                         if(Node->Special.Button.ExtraFat)
  332.                         {
  333.                             Node->Width        = 6 + Handle->GlyphWidth + Node->Width + Handle->GlyphWidth + 6;
  334.                             Node->Height    = 2 + (3 * Handle->GlyphHeight) / 2 + 2;
  335.                         }
  336.                         else
  337.                         {
  338.                             if(Node->Special.Button.Smaller)
  339.                             {
  340.                                 Node->Width        = 4 + Node->Width + 4;
  341.                                 Node->Height    = 2 + Handle->GlyphHeight + 2;
  342.                             }
  343.                             else
  344.                             {
  345.                                 Node->Width        = 6 + Node->Width + 6;
  346.                                 Node->Height    = 3 + Handle->GlyphHeight + 3;
  347.                             }
  348.                         }
  349.                     }
  350.                 }
  351.  
  352.                 Node->LabelWidth = 0;
  353.                 Node->LabelPlace = PLACE_IN;
  354.  
  355.                 break;
  356.  
  357.             case CHECKBOX_KIND:
  358.  
  359. /*                Node->Width = Node->Height = (4 * Handle->GlyphHeight) / 3;*/
  360.                 Node->Width = Node->Height = Handle->RPort.TxBaseline + ((Handle->RPort.TxBaseline + 2) / 3) * 2;
  361.  
  362.                 if(Node->Height < CHECKBOX_HEIGHT)
  363.                     Node->Height = CHECKBOX_HEIGHT;
  364.  
  365.                 if(!V39)
  366.                 {
  367.                     if(Node->Width < CHECKBOX_WIDTH)
  368.                         Node->Width = CHECKBOX_WIDTH;
  369.                 }
  370.                 else
  371.                     Node->Width = (Node->Height * Handle->AspectY) / Handle->AspectX;
  372.  
  373.                 break;
  374.  
  375.             case LISTVIEW_KIND:
  376.             {
  377.                 struct TextFont    *Font,*OldFont;
  378.                 LONG             GlyphWidth;
  379.  
  380.                 if(Node->Lines < 1)
  381.                 {
  382.                     Handle->Failed = TRUE;
  383.  
  384.                     return;
  385.                 }
  386.  
  387.                 if(Node->Special.List.TextAttr)
  388.                 {
  389.                     if(!(Font = LTP_OpenFont(Node->Special.List.TextAttr)))
  390.                     {
  391.                         Handle->Failed = TRUE;
  392.  
  393.                         return;
  394.                     }
  395.  
  396.                         // Is this a fixed-width font?
  397.  
  398.                     if(Font->tf_Flags & FPF_PROPORTIONAL)
  399.                     {
  400.                             // We don't want it
  401.  
  402.                         CloseFont(Font);
  403.  
  404.                         Handle->Failed = TRUE;
  405.  
  406.                         return;
  407.                     }
  408.  
  409.                     OldFont = Handle->RPort.Font;
  410.  
  411.                     SetFont(&Handle->RPort,Font);
  412.  
  413.                     GlyphWidth = Handle->RPort.TxWidth;
  414.  
  415.                     Node->Special.List.FixedGlyphWidth    = Handle->RPort.TxWidth;
  416.                     Node->Special.List.FixedGlyphHeight    = Handle->GlyphHeight;
  417.                 }
  418.                 else
  419.                 {
  420.                     Font        = NULL;
  421.                     GlyphWidth    = Handle->GlyphWidth;
  422.                 }
  423.  
  424.                 i        = 0;
  425.                 Max        = 0;
  426.                 Width    = Node->Chars * GlyphWidth;
  427.  
  428.                 if((ULONG)Node->Special.List.Labels == 0xFFFFFFFF)
  429.                     Node->Min = Node->Max = -1;
  430.                 else
  431.                 {
  432.                     if(Node->Special.List.Labels)
  433.                     {
  434.                         struct Node *Item;
  435.  
  436.                         SCANLIST(Node->Special.List.Labels,Item)
  437.                         {
  438.                             i++;
  439.  
  440.                             if((Len = TextLength(&Handle->RPort,Item->ln_Name,strlen(Item->ln_Name))) > Max)
  441.                                 Max = Len;
  442.                         }
  443.                     }
  444.  
  445.                     if(Node->Special.List.IgnoreListContents)
  446.                         Max = 0;
  447.  
  448.                     Node->Max = i - 1;
  449.                 }
  450.  
  451.                 if(Max > Width && !Node->Special.List.SizeLocked)
  452.                 {
  453.                     Width = Max;
  454.  
  455.                     Node->Chars = (Width + GlyphWidth - 1) / GlyphWidth;
  456.  
  457.                     Width = Node->Chars * GlyphWidth;
  458.                 }
  459.  
  460.                 if(Node->Special.List.LockSize)
  461.                     Node->Special.List.SizeLocked = TRUE;
  462.  
  463.                 if(!V39)
  464.                     Node->Width = (4 + Width + 4) + (2 + 2 * Handle->GlyphWidth + 2) + 8;
  465.                 else
  466.                     Node->Width = (4 + Width + 4) + (2 + 2 * Handle->GlyphWidth + 2);
  467.  
  468.                 Node->Height = 2 + Node->Lines * Handle->GlyphHeight + 2;
  469.  
  470.                 if(Node->Special.List.ReadOnly)
  471.                 {
  472.                     if(Node->Special.List.LinkID != -1)
  473.                     {
  474.                         if(!V39)
  475.                             Node->Height += 2 + Handle->GlyphHeight + 2;
  476.                     }
  477.                 }
  478.                 else
  479.                 {
  480.                     if(Node->Special.List.LinkID == NIL_LINK)
  481.                     {
  482.                         if(!V39)
  483.                             Node->Height += 2 + Handle->GlyphHeight + 2;
  484.                     }
  485.                     else
  486.                     {
  487.                         if(Node->Special.List.LinkID != -1 && Node->Special.List.LinkID != NIL_LINK)
  488.                             Node->Height += 3 + Handle->GlyphHeight + 3;
  489.                     }
  490.                 }
  491.  
  492.                     // Switch back to the window font
  493.  
  494.                 if(Font)
  495.                 {
  496.                     SetFont(&Handle->RPort,OldFont);
  497.  
  498.                     CloseFont(Font);
  499.                 }
  500.  
  501.                 if(Node->Special.List.ExtraLabels)
  502.                 {
  503.                     for(i = Max = 0 ; Node->Special.List.ExtraLabels[i] ; i++)
  504.                     {
  505.                         if((Len = TextLength(&Handle->RPort,Node->Special.List.ExtraLabels[i],strlen(Node->Special.List.ExtraLabels[i]))) > Max)
  506.                             Max = Len;
  507.                     }
  508.  
  509.                     Node->Special.List.ExtraLabelWidth = Max;
  510.                 }
  511.  
  512.                 break;
  513.             }
  514.  
  515.             case MX_KIND:
  516.  
  517.                 i    = 0;
  518.                 Max    = 0;
  519.  
  520.                 while(Node->Special.Radio.Choices[i])
  521.                 {
  522.                     if((Width = TextLength(&Handle->RPort,Node->Special.Radio.Choices[i],strlen(Node->Special.Radio.Choices[i]))) > Max)
  523.                         Max = Width;
  524.  
  525.                     i++;
  526.                 }
  527.  
  528.                 Node->Max = i - 1;
  529.  
  530.                 Node->Special.Radio.LabelWidth = Max;
  531.  
  532.                 if(Node->LabelChars * Handle->GlyphWidth > Node->LabelWidth)
  533.                     Node->LabelWidth = Node->LabelChars * Handle->GlyphWidth;
  534.  
  535.                 Node->Height = MAX(MX_HEIGHT,Handle->GlyphHeight);
  536.  
  537.                 if(!V39)
  538.                     Node->Width = MX_WIDTH;
  539.                 else
  540.                 {
  541.                     Node->Width = (Node->Height * Handle->AspectY) / Handle->AspectX;
  542.  
  543.                     if(Node->Height < MX_HEIGHT)
  544.                     {
  545.                         Node->Height = MX_HEIGHT;
  546.                         Node->Width  = (Node->Height * Handle->AspectX) / Handle->AspectY;
  547.                     }
  548.                 }
  549.  
  550.                 Node->Lines  = i;
  551.                 Node->Height = Node->Lines * (Node->Height + Handle->InterHeight) - Handle->InterHeight;
  552.  
  553.                 break;
  554.  
  555. #ifdef DO_GAUGE_KIND
  556.             case GAUGE_KIND:
  557.  
  558.                 Width = TextLength(&Handle->RPort,"0%100%",6) + 2 * Handle->GlyphWidth;
  559.  
  560.                 if(Handle->GlyphWidth * Node->Chars > Width)
  561.                     Width = Handle->GlyphWidth * Node->Chars;
  562.  
  563.                 Node->Width = 6 + Width + 6;
  564.  
  565.                 if(Node->Special.Gauge.NoTicks)
  566.                     Node->Height = 3 + Handle->GlyphHeight + 3;
  567.                 else
  568.                     Node->Height = 3 + Handle->GlyphHeight + 2 + Handle->InterHeight + Handle->GlyphHeight + 3;
  569.  
  570.                 if(Node->Special.Gauge.Discrete)
  571.                 {
  572.                     Width = ((Node->Width - 6 - 6) + 9) / 10;
  573.  
  574.                     Node->Width = 2 + Width * 10 + 2;
  575.                 }
  576.  
  577.                 break;
  578. #endif
  579.  
  580. #ifdef DO_TAPEDECK_KIND
  581.             case TAPEDECK_KIND:
  582.             {
  583.                 LONG Width,Height,OrigWidth,Attempt = 4;
  584.  
  585.                 Width = TextLength(&Handle->RPort,"AA",2);
  586.  
  587.                 if(Width < 2 * Handle->GlyphWidth);
  588.                     Width = 2 * Handle->GlyphWidth;
  589.  
  590.                 if(Width < 2 * Handle->GlyphHeight)
  591.                     Width = 2 * Handle->GlyphHeight;
  592.  
  593.                 if(Node->Special.TapeDeck.Smaller)
  594.                     Width = (3 * Width) / 4;
  595.  
  596.                 if(Width & 1)
  597.                     Width++;
  598.  
  599.                 OrigWidth = Width;
  600.  
  601.                 do
  602.                 {
  603.                     Width    = 1 + ((((OrigWidth + 5) / 6) * 6) & ~1);
  604.                     Height    = (Handle->AspectX * Width) / (Handle->AspectY * 2);
  605.  
  606.                     OrigWidth += 2;
  607.                     Attempt--;
  608.                 }
  609.                 while(Height < 6 && Attempt > 0);
  610.  
  611.                 if(!(Height & 1))
  612.                     Height++;
  613.  
  614.                 if(Node->Special.TapeDeck.ButtonType == TDBT_BACKWARD || Node->Special.TapeDeck.ButtonType == TDBT_FORWARD)
  615.                     Node->Special.TapeDeck.ButtonWidth = Width;
  616.                 else
  617.                     Node->Special.TapeDeck.ButtonWidth = Width / 2;
  618.  
  619.                 Node->Special.TapeDeck.ButtonHeight = Height;
  620.  
  621.                 if(Handle->GlyphWidth * Node->Chars > Width)
  622.                     Width = Handle->GlyphWidth * Node->Chars;
  623.  
  624.                 Node->Width        = 6 + Width + 6;
  625.                 Node->Height    = 3 + Height + 3;
  626.  
  627.                 break;
  628.             }
  629. #endif    /* DO_TAPEDECK_KIND */
  630.  
  631.             case CYCLE_KIND:
  632.  
  633.                     // NOTE: This does not include the width of the
  634.                     //       cycle glyph which is by default 26 pixels
  635.                     //       wide.
  636.  
  637.                 Node->Width = 6 + Node->Chars * Handle->GlyphWidth + 6;
  638.  
  639.                 Width = 0;
  640.  
  641.                 if(Node->Special.Cycle.Choices)
  642.                 {
  643.                     for(i = 0 ; Node->Special.Cycle.Choices[i] ; i++)
  644.                     {
  645.                         if((Len = TextLength(&Handle->RPort,Node->Special.Cycle.Choices[i],strlen(Node->Special.Cycle.Choices[i]))) > Width)
  646.                             Width = Len;
  647.                     }
  648.  
  649.                     Node->Max = i - 1;
  650.                 }
  651.  
  652.                 Max = 6 + Width + 6;
  653.  
  654.                 if(Node->Width < Max)
  655.                     Node->Width = Max;
  656.  
  657.                     // Add the remainder of the cycle glyph
  658.  
  659.                 Node->Width += 20;
  660.  
  661.                 Node->Height = 3 + Handle->GlyphHeight + 3;
  662.  
  663.                 break;
  664.  
  665. #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
  666.             case POPUP_KIND:
  667.  
  668.                     // NOTE: This is the number of pixels the popup glyph
  669.                     //       will need. It will not enter the calculation
  670.                     //       until the maximum size of the hit box is
  671.                     //       calculated.
  672.  
  673.                 Plus = (4 + ((TextLength(&Handle->RPort,"M",1) & ~1) + 1) + 2 + 4) + (Handle->GlyphHeight * Handle->DrawInfo->dri_Resolution.Y) / Handle->DrawInfo->dri_Resolution.X + 2;
  674.  
  675.                 Node->Width = 6 + Node->Chars * Handle->GlyphWidth + 6;
  676.  
  677.                 Width = 0;
  678.  
  679.                 if(Node->Special.Popup.Choices)
  680.                 {
  681.                     for(i = 0 ; Node->Special.Popup.Choices[i] ; i++)
  682.                     {
  683.                         if((Len = TextLength(&Handle->RPort,Node->Special.Popup.Choices[i],strlen(Node->Special.Popup.Choices[i]))) > Width)
  684.                             Width = Len;
  685.                     }
  686.  
  687.                     Node->Max = i - 1;
  688.                 }
  689.  
  690.                 Max = 6 + Width + 6;
  691.  
  692.                 if(Node->Width < Max)
  693.                     Node->Width = Max;
  694.  
  695.                     // Add the glyph width
  696.  
  697.                 Node->Width += Plus;
  698.  
  699.                 Node->Height = 3 + Handle->GlyphHeight + 3;
  700.  
  701.                 break;
  702. #endif
  703.  
  704. #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
  705.             case TAB_KIND:
  706.  
  707.                 if(!Node->Special.Tab.Choices)
  708.                     Handle->Failed = TRUE;
  709.                 else
  710.                 {
  711.                     struct IBox Box;
  712.  
  713.                     Width = Node->Chars * Handle->GlyphWidth;
  714.  
  715.                     for(i = 0 ; Node->Special.Tab.Choices[i] ; i++);
  716.  
  717.                     Node->Max = i - 1;
  718.  
  719.                     Node->Label = NULL;
  720.  
  721.                     if(!LTP_ObtainTabSize(&Box,
  722.                         TIA_Labels,        Node->Special.Tab.Choices,
  723.                         TIA_DrawInfo,    Handle->DrawInfo,
  724.                         TIA_Font,        Handle->TextAttr,
  725.                         TIA_SizeType,    GDOMAIN_MINIMUM,
  726.                     TAG_DONE))
  727.                         Handle->Failed = TRUE;
  728.                     else
  729.                     {
  730.                         if(Width < Box.Width)
  731.                             Width = Box.Width;
  732.  
  733.                         Node->Width        = Width;
  734.                         Node->Height    = Box.Height;
  735.                     }
  736.                 }
  737.  
  738.                 break;
  739. #endif
  740.             case PALETTE_KIND:
  741.  
  742.                 if(Node->Special.Palette.UsePicker)
  743.                 {
  744.                     Node->Height = 3 + Handle->GlyphHeight + 3;
  745.                     Node->Width = (Node->Height * Handle->AspectY) / Handle->AspectX;
  746.  
  747.                     Node->Special.Palette.IndicatorWidth = Node->Width;
  748.  
  749.                     Node->Width += LTP_GetPickerSize(Handle);
  750.                 }
  751.                 else
  752.                 {
  753.                     if(Node->Special.Palette.NumColours)
  754.                         Node->Max = Node->Min + Node->Special.Palette.NumColours - 1;
  755.                     else
  756.                     {
  757.                         if(!Node->Special.Palette.Depth)
  758.                             Node->Special.Palette.Depth = 1;
  759.  
  760.                         Node->Special.Palette.NumColours = 1L << Node->Special.Palette.Depth;
  761.  
  762.                         Node->Max = Node->Min + Node->Special.Palette.NumColours - 1;
  763.                     }
  764.  
  765.                     if(Node->Special.Palette.SmallPalette)
  766.                     {
  767.                         Node->Width        = Handle->GlyphWidth * (Node->Max - Node->Min + 1) + 4;
  768.                         Node->Height    = 1 + Handle->GlyphHeight + 1;
  769.  
  770.                         if((Node->Width - 4) / (Node->Max - Node->Min + 1) < 8 && Node->Height < 2 * 8)
  771.                             Node->Width = 8 * (Node->Max - Node->Min + 1) + 4;
  772.  
  773.                         Node->Width += 2 * Handle->GlyphWidth;
  774.                     }
  775.                     else
  776.                     {
  777.                         Node->Width        = 2 * Handle->GlyphWidth * (Node->Max - Node->Min + 1);
  778.                         Node->Height    = 2 * Handle->GlyphHeight;
  779.                     }
  780.  
  781.                     if(Node->Width < 20)
  782.                         Node->Width = 20;
  783.  
  784.                     if(Node->Chars * Handle->GlyphWidth > Node->Width)
  785.                         Node->Width = Node->Chars * Handle->GlyphWidth;
  786.  
  787.                     if(Node->Special.Palette.NumColours > 16)
  788.                     {
  789.                         Node->Height    *= 2;
  790.                         Node->Width        /= 2;
  791.                     }
  792.  
  793.                     if(Node->Lines)
  794.                     {
  795.                         if(!Node->Chars)
  796.                             Node->Width = Handle->GlyphWidth;
  797.                         else
  798.                             Node->Width = Node->Chars * Handle->GlyphWidth;
  799.  
  800.                         Node->Height = Node->Lines * Handle->GlyphHeight;
  801.                     }
  802.  
  803.                     if(Node->Special.Palette.ColourTable && !Node->Special.Palette.TranslateBack)
  804.                     {
  805.                         if(Node->Special.Palette.TranslateBack = LTP_Alloc(Handle,256))
  806.                         {
  807.                             LONG i;
  808.  
  809.                             for(i = Node->Min ; i <= Node->Max ; i++)
  810.                                 Node->Special.Palette.TranslateBack[Node->Special.Palette.ColourTable[i]] = i;
  811.                         }
  812.                     }
  813.                 }
  814.  
  815.                 break;
  816.  
  817.             case SCROLLER_KIND:
  818.  
  819.                 if(Node->Special.Scroller.Vertical)
  820.                 {
  821.                     if(Node->Special.Scroller.Thin)
  822.                         Node->Width = 6 + Handle->GlyphWidth + 6;
  823.                     else
  824.                         Node->Width = 6 + (3 * Handle->GlyphWidth) / 2 + 6;
  825.  
  826.                     Node->Height = 2 + Node->Lines * Handle->GlyphHeight;
  827.  
  828.                     if(Node->Special.Scroller.Arrows)
  829.                     {
  830.                         LONG ScrollerHeight = (Handle->AspectX * Node->Width) / Handle->AspectY;
  831.  
  832.                         if(Node->Height < 2 + Node->Lines * Handle->GlyphHeight + 2 * ScrollerHeight)
  833.                             Node->Height = 2 + Node->Lines * Handle->GlyphHeight + 2 * ScrollerHeight;
  834.  
  835.                         Node->Special.Scroller.ArrowSize = ScrollerHeight;
  836.                     }
  837.                 }
  838.                 else
  839.                 {
  840.                     Node->Width  = 6 + Node->Chars * Handle->GlyphWidth + 6;
  841.                     Node->Height = 2 + Handle->GlyphHeight;
  842.  
  843.                     if(Node->Special.Scroller.Arrows)
  844.                     {
  845.                         LONG ScrollerWidth = (Handle->AspectY * Node->Height) / Handle->AspectX;
  846.  
  847.                         if(Node->Width < 6 + Handle->GlyphWidth + 2 * ScrollerWidth + 6)
  848.                             Node->Width = 6 + Handle->GlyphWidth + 2 * ScrollerWidth + 6;
  849.  
  850.                         Node->Special.Scroller.ArrowSize = ScrollerWidth;
  851.                     }
  852.                 }
  853.  
  854.                 break;
  855.  
  856.             case SLIDER_KIND:
  857.             {
  858.                 BOOL CheckIt;
  859.  
  860.                 Node->Width        = 6 + Node->Chars * Handle->GlyphWidth + 6;
  861.                 Node->Height    = 2 + Handle->GlyphHeight + 2;
  862.  
  863.                 CheckIt = (!Node->Special.Slider.MaxLevelLen || !Node->Special.Slider.LevelWidth || Handle->Rescaled);
  864.  
  865.                 if(Node->Special.Slider.LevelFormat && CheckIt)
  866.                     LTP_LevelWidth(Handle,Node->Special.Slider.LevelFormat,Node->Special.Slider.DispFunc,Node->Min,Node->Max,&Node->Special.Slider.LevelWidth,&Node->Special.Slider.MaxLevelLen,Node->Special.Slider.FullLevelCheck);
  867.  
  868.                 if(Node->Special.Slider.LevelFormat && !V40)
  869.                 {
  870.                     if(Node->Special.Slider.MaxLevelLen * Handle->RPort.TxWidth < Node->Special.Slider.LevelWidth)
  871.                         Node->Special.Slider.MaxLevelLen = (Node->Special.Slider.LevelWidth + Handle->RPort.TxWidth - 1) / Handle->RPort.TxWidth;
  872.                 }
  873.  
  874.                 if(Node->Special.Slider.LevelFormat && Node->Special.Slider.LevelPlace == PLACETEXT_LEFT && Node->LabelPlace == PLACE_LEFT && Node->Label && CheckIt)
  875.                 {
  876.                     LONG    space,len;
  877.                     STRPTR    Buffer;
  878.  
  879.                     space = TextLength(&Handle->RPort," ",1);
  880.                     space = (Node->Special.Slider.LevelWidth + space - 1) / space;
  881.  
  882.                     if(!V40 && (Handle->RPort.TxFlags & FPF_PROPORTIONAL))
  883.                     {
  884.                         Node->Special.Slider.MaxLevelLen++;
  885.  
  886.                         space++;
  887.                     }
  888.  
  889.                     if(Node->Special.Slider.OriginalLabel)
  890.                         LTP_Free(Handle,Node->Label,strlen(Node->Label) + 1);
  891.                     else
  892.                         Node->Special.Slider.OriginalLabel = Node->Label;
  893.  
  894.                     len = strlen(Node->Special.Slider.OriginalLabel);
  895.  
  896.                     if(Buffer = LTP_Alloc(Handle,len + space + 1))
  897.                     {
  898.                         strcpy(Buffer,Node->Special.Slider.OriginalLabel);
  899.  
  900.                         while(space > 0)
  901.                         {
  902.                             Buffer[len] = ' ';
  903.                             len++;
  904.                             space--;
  905.                         }
  906.  
  907.                         Buffer[len] = 0;
  908.  
  909.                         Node->Label            = Buffer;
  910.                         Node->LabelWidth    = LT_LabelWidth(Handle,Node->Label);
  911.                     }
  912.                     else
  913.                         break;
  914.                 }
  915.  
  916.                 if(Node->LabelChars * Handle->GlyphWidth > Node->LabelWidth)
  917.                     Node->LabelWidth = Node->LabelChars * Handle->GlyphWidth;
  918.  
  919.                 break;
  920.             }
  921.  
  922.             case TEXT_KIND:
  923.  
  924.                 if(Node->Special.Text.Text && !Node->Special.Text.SizeLocked)
  925.                     Max = TextLength(&Handle->RPort,Node->Special.Text.Text,strlen(Node->Special.Text.Text));
  926.                 else
  927.                     Max = 0;
  928.  
  929.                 Width = Node->Chars * Handle->GlyphWidth;
  930.  
  931.                 if(!Node->Special.Text.SizeLocked && Node->Special.Text.LockSize)
  932.                 {
  933.                     LONG Chars = (Width + Handle->GlyphWidth - 1) / Handle->GlyphWidth;
  934.  
  935.                     if(Chars > Node->Chars)
  936.                         Node->Chars = Chars;
  937.  
  938.                     Max = Width = Node->Chars * Handle->GlyphWidth;
  939.                 }
  940.  
  941.                 if(Max > Width)
  942.                     Width = Max;
  943.  
  944.                 Node->Width        = 6 + Width + 6;
  945.                 Node->Height    = 3 + Handle->GlyphHeight + 3;
  946.  
  947.                 if(Node->Special.Text.UsePicker)
  948.                     Node->Width += LTP_GetPickerSize(Handle);
  949.  
  950.                 if(Node->Special.Text.LockSize)
  951.                     Node->Special.Text.SizeLocked = TRUE;
  952.  
  953.                 break;
  954.  
  955.             case NUMBER_KIND:
  956.             case INTEGER_KIND:
  957.             case STRING_KIND:
  958.             case PASSWORD_KIND:
  959.             case FRACTION_KIND:
  960.  
  961.                 Node->Width        = 6 + Node->Chars * Handle->GlyphWidth + 6;
  962.                 Node->Height    = 3 + Handle->GlyphHeight + 3;
  963.  
  964.                 if(Node->Type == STRING_KIND && Node->Special.String.UsePicker)
  965.                     Node->Width += LTP_GetPickerSize(Handle);
  966.  
  967.                 if(Node->Type == INTEGER_KIND && Node->Special.Integer.UseIncrementers)
  968.                     Node->Width += 2 * (4 + Handle->GlyphWidth + 4);
  969.  
  970.                 break;
  971.         }
  972.  
  973.         if(Node->LabelWidth > Node->Width && (Node->LabelPlace == PLACE_ABOVE || Node->LabelPlace == PLACE_BELOW))
  974.             Node->Width = Node->LabelWidth;
  975.     }
  976. }
  977.